package com.attendance.model.Result;

/**
 * Created by inuyasha on 2016/11/29.
 */
public enum ResultCode {

    //basic code
    SUCCESS("SUCCESS", "操作成功"),
    SYSTEM_FAILURE("SYSTEM_FAILURE", "系统错误"),
    NOT_SUPPORT("NOT_SUPPORT", "系统不支持该功能"),
    NULL_ARGUMENT("NULL_ARGUMENT", "参数为空"),
    ILLEGAL_ARGUMENT("ILLEGAL_ARGUMENT", "参数不正确"),
    IO_FAILURE("IO_FAILURE", "IO错误"),
    PARTIAL_FAILURE("PARTIAL_FAILURE", "部分失败"),

    //apply 业务
    APPLY_ADD_ERROR("APPLY_ADD_ERROR", "添加申请操作失败"),
    APPLY_DELETE_ERROR("APPLY_DELETE_ERROR", "删除申请操作失败"),
    APPLY_UPDATE_ERROR("APPLY_UPDATE_ERROR", "更新申请操作失败"),
    //employee 业务
    EMPLOYEE_ADD_ERROR("EMPLOYEE_ADD_ERROR", "添加雇员操作失败"),
    EMPLOYEE_DELETE_ERROR("EMPLOYEE_DELETE_ERROR", "删除雇员操作失败"),
    EMPLOYEE_UPDATE_ERROR("EMPLOYEE_UPDATE_ERROR", "更新雇员操作失败"),
    //department 业务
    DEPARTMENT_ADD_ERROR("DEPARTMENT_ADD_ERROR", "添加部门操作失败"),
    DEPARTMENT_DELETE_ERROR("DEPARTMENT_DELETE_ERROR", "删除部门操作失败"),
    DEPARTMENT_UPDATE_ERROR("DEPARTMENT_UPDATE_ERROR", "更新部门操作失败"),
    //vacation 业务
    VACATION_ADD_ERROR("VACATION_ADD_ERROR", "添加假期操作失败"),
    VACATION_DELETE_ERROR("VACATION_DELETE_ERROR", "删除假期操作失败"),
    VACATION_UPDATE_ERROR("VACATION_UPDATE_ERROR", "更新假期操作失败"),
    //type 业务
    TYPE_ADD_ERROR("TYPE_ADD_ERROR", "添加假期类型操作失败"),
    TYPE_DELETE_ERROR("TYPE_DELETE_ERROR", "删除假期类型操作失败"),
    TYPE_UPDATE_ERROR("TYPE_UPDATE_ERROR", "更新假期类型操作失败"),
    //record 业务
    RECORD_ADD_ERROR("RECORD_ADD_ERROR", "添加打卡记录操作失败"),
    RECORD_DELETE_ERROR("RECORD_DELETE_ERROR", "删除打卡记录操作失败"),
    RECORD_UPDATE_ERROR("RECORD_UPDATE_ERROR", "更新打卡记录操作失败");

    private String value;
    private String message;

    ResultCode(String value, String message) {
        this.value = value;
        this.message = message;
    }

    /**
     * 根据枚举值获取枚举对象，如果找不到对应的枚举返回<code>null</code>
     *
     * @param value 枚举值
     * @return 枚举对象
     */
    public static ResultCode getEnumByValue(String value) {
        for (ResultCode resultCode : ResultCode.values()) {
            if (resultCode.getValue().equals(value)) {
                return resultCode;
            }
        }
        return null;
    }

    public String getValue() {
        return value;
    }

    public String getMessage() {
        return message;
    }


}
